package com.wy.powerbuilder.service.impl.ljh;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wy.powerbuilder.entity.ljh.Device;
import com.wy.powerbuilder.entity.ljh.Repair;
import com.wy.powerbuilder.entity.lwg.houses;
import com.wy.powerbuilder.mapper.ljh.RepairMapper;
import com.wy.powerbuilder.service.ljh.RepairService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;
@Service
public class RepairServiceImpl implements RepairService {
    @Autowired
    private RepairMapper repairMapper;
    @Override
    public PageInfo<Repair> selByPage(Integer pageNum, Integer pageSize,String r_userName) {
        if (pageNum==null){
            pageNum=1;
        }
        /*

        对查询的信息进行分页
        第一个参数当前页码,第二个每页的条数
        */
        PageHelper.startPage(pageNum,pageSize) ; //使用分页插件开始分页
        //查询我们将要分页的信息
        List<Repair> repairs = repairMapper.selAll(r_userName);

        //将查询的维修信息放到分页对象中去
        PageInfo<Repair> pageInfo = new PageInfo<>(repairs);
        return pageInfo;
    }
    public int addRepair(Repair repair){
        return repairMapper.addRepair(repair);
    }

    @Override
    public int delRepair(Integer r_id) {
        return repairMapper.delRepair(r_id);
    }

    @Override
    public int updRepair(Repair repair) {
        return repairMapper.updRepair(repair);
    }

    @Override
    public Repair selectId(Integer r_id) {
        return repairMapper.selectId(r_id);
    }
    @Override
    public List<houses> seleAll() {
        return repairMapper.seleAll();
    }

    @Override
    public List<Device> showDevice() {
        return repairMapper.showDevice();
    }

    @Override
    public int sum() {
        return repairMapper.sum();
    }
}
